DISCONTINUED: Along with my mail server I switched to a hoster as I had not enough time to keep everything running smoothly and secure. (Switched to mailbox.org)
.
Tested for Ubuntu 18.04
Requires an already setup Apache2 + LetsEncrypt
Install
Data Folder
mkdir /var/radicale
chown www-data /var/radicale
Radicale & Reqs
apt-get install python3-pip
python3 -m pip install --upgrade radicale
python3 -m pip install --upgrade git+https://github.com/Unrud/RadicaleIMAP
python3 -m pip install --upgrade git+https://github.com/Unrud/RadicaleInfCloud
Apache2 Requirements (for WSGI)
apt-get install libapache2-mod-wsgi-py3
a2enmod wsgi
Config
/var/radicale/config
[server]
hosts = 0.0.0.0:5232
[auth]
type = radicale_imap
imap_host = mail.example.net
imap_secure = True
[storage]
filesystem_folder = /var/radicale/collections
[logging]
config = /var/radicale/logging
debug = True
[web]
type = radicale_infcloud
/var/radicale/logging
[loggers]
keys = root
[handlers]
keys = file
[formatters]
keys = full
[logger_root]
# DEBUG,INFO, WARNING
# level = WARNING
handlers = file
[handler_file]
args = ('/var/radicale/logs/radicale.log','a',1000000,2)
class = handlers.RotatingFileHandler
formatter = full
level = INFO
[formatter_full]
format = %(asctime)s - %(levelname)s: %(message)s
WSGI setup
/var/radicale/radicale.wsgi
import os
from radicale import Application, config, log
configuration = config.load(["/var/radicale/config"])
filename = os.path.expanduser(configuration.get("logging", "config"))
debug = configuration.getboolean("logging", "debug")
logger = log.start("radicale", filename, debug)
application = Application(configuration, logger)
apache2.conf
<VirtualHost *:443>
ServerName dav.example.net
DocumentRoot /var/radicale/
WSGIDaemonProcess radicale user=www-data group=www-data threads=1
WSGIScriptAlias / /var/radicale/radicale.wsgi
WSGIPassAuthorization On
<Directory /var/radicale/>
WSGIProcessGroup radicale
WSGIApplicationGroup %{GLOBAL}
AllowOverride None
SSLRequireSSL
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/dav.example.net/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/dav.example.net/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/dav.example.net/chain.pem
</VirtualHost>
Addon: Sync external sources into an own CalDav Calender:
/var/radicale/sync-external.sh
#!/bin/bash
cd collections/collection-root/user@domain.tld/cal-holidays/
# Ferien
wget -q http://i.cal.to/ical/78/rheinland-pfalz/ferien/6d6f0645.5fe5a2e8-b813d8cb.ics -O icalto-ferien.ics
rm -f icalto-ferien-item*
csplit -sf icalto-ferien-item -b %03d.ics icalto-ferien.ics /BEGIN:VEVENT/ {*}
rm icalto-ferien.ics
# Feiertage
wget -q http://i.cal.to/ical/62/rheinland-pfalz/feiertage/6d6f0645.5fe5a2e8-7da4ef30.ics -O icalto-feiertage.ics
rm -f icalto-feiertage-item*
csplit -sf icalto-feiertage-item -b %03d.ics icalto-feiertage.ics /BEGIN:VEVENT/ {*}
rm icalto-feiertage.ics
# Remove "first" (empty)
rm -f icalto-*-item000.ics
# Remove Stuff after last event
find . -name 'icalto-*.ics' -exec sed -i '/END:VEVENT/q' {} \;
# Remove undesired fields
sed -i -r "/^(URL|DESCRIPTION|SEQUENCE|STATUS|X-MICROSOFT-CDO-ALLDAYEVENT):/d" icalto-*.ics
# remove rest of description (starting with blank)
sed -i -r "/^ /d" icalto-*.ics
sed -i "s/ - presented by calovo\.de//" icalto-*.ics
# Prepend and Append VCALENDAR
sed -i "s/BEGIN:VEVENT/BEGIN:VCALENDAR\nBEGIN:VEVENT/" icalto-*.ics
sed -i "s/END:VEVENT/END:VEVENT\nEND:VCALENDAR/" icalto-*.ics
echo "Done."
Addon: Export calender to single ics (possibly w/o auth, or for unsupported clients)
/var/radicale/config
[storage]
hook = curl --user 'user:password' --silent 'http://localhost:5232/user/calendar/' --output '/path/to/Sync/calendar.ics' &
TODO: Have to look into some locking issues with WSGI and Radicale and Hooks